#!/bin/bash

# 清除上个赛季竞赛信息

HOSTNAME=rm-wz9fyot11c623370neo.mysql.rds.aliyuncs.com
DB_PORT=3306
USERNAME=fthadmin
PASSWORD=Swift2020

IFS=$'\n\n'
DBNAME=($(cat ./mysql_db_list.conf | grep -v '#' | awk -F, '{print $0}'))
DELETE_TABLE_SQL=($(cat ./mysql_truncate_list.conf | grep -v '#' | awk -F, '{print $0}'))

for DB in ${DBNAME[*]}; do
    for DELETE_SQL in ${DELETE_TABLE_SQL[*]}; do
        echo $DB ----------------
        echo $DELETE_SQL ----------------
        mysql -h ${HOSTNAME} -P${DB_PORT} -u ${USERNAME} -p${PASSWORD} -D ${DB} -e "${DELETE_SQL}"
    done
done
